
const fileService = require("../../service/web/fileService");

module.exports = ({ app, router }) => {
    // 定义读取文件的路由
    router.get('/fileTree', async (req, res) => {
        const result = await fileService.getFileTreeService(req, res);
        res.send(result);
    });
    router.get('/video', async (req, res) => {
        const fs = require('fs');
        // const readStream = fs.createReadStream(req.query.path, { highWaterMark: 1024 * 1024 }); // 每次发送1MB数据
        // readStream.on('data', (chunk) => {
        //     console.log(chunk);
        // });
        // res.reject('/video-stream');
        // const result = await fileService.getVideoFileService(req, res);
        if (req.query.path) {
            // console.log(req.query.path);
            // const videoStream = fs.readFileSync(req.query.path);
            // console.log(videoStream);
            // res.send({ binaryData: videoStream })
        }
    });
}